/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.gui;

import java.awt.Frame;
import java.io.File;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import program.beans.Bill;
import program.beans.BillAmount;
import program.beans.Category;
import program.beans.Company;
import program.database.Database;
import program.gui.model.AmountTableModel;
import program.gui.model.CategoryComboBoxModel;

/**
 *
 * Responsible: Patrick, Bernhard
 */
public class NewBillDlg extends javax.swing.JDialog {

    private AmountTableModel amountTableModel;
    private ArrayList<BillAmount> amounts = new ArrayList<>();
    private CategoryComboBoxModel categoryComboBoxModel;
    private Database db = Database.getDatabase();
    private File billCopy;
    private Bill bill;
    private boolean ok;
    private Company selectedComp;

    /**
     * Creates new form NewBillDlg
     */
    public NewBillDlg(Frame parent, boolean modal, Bill b) {
        super(parent, modal);
        initComponents();
        buttonGroup1.add(rbOutgoing);
        buttonGroup1.add(rbEarning);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        amountTableModel = new AmountTableModel(amounts);
        tbAmounts.setModel(amountTableModel);
        try {
            categoryComboBoxModel = new CategoryComboBoxModel(db.getAllCategories());
        } catch (Exception ex) {
                       JOptionPane.showMessageDialog(null, ex);

        }
        cbCategories.setModel(categoryComboBoxModel);
        if(categoryComboBoxModel.getSize() > 0)
         cbCategories.setSelectedIndex(0);
        buttonGroup1.setSelected(rbOutgoing.getModel(), true);
        
        if(b != null)
        {
            if(b.getType() == 0)
                buttonGroup1.setSelected(rbOutgoing.getModel(), true);
            else
                buttonGroup1.setSelected(rbEarning.getModel(), true);
            
            tfCompany.setText(b.getComp().getName());
            tfBrutto.setText(b.getAllBruttoAmountsFormated());
            tfNetto.setText(b.getAllNettoAmountsFormated());
            amounts.clear();
            amounts.addAll(b.getAmounts());
            tbAmounts.updateUI();
            categoryComboBoxModel.setSelectedItem(b.getCat().getDescription());
            dpDate.setDate(b.getDate());
            selectedComp = b.getComp();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        rbEarning = new javax.swing.JRadioButton();
        rbOutgoing = new javax.swing.JRadioButton();
        pnMain = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbAmounts = new javax.swing.JTable();
        btNewAmount = new javax.swing.JButton();
        lbFirma = new javax.swing.JLabel();
        lbDatum = new javax.swing.JLabel();
        tfCompany = new javax.swing.JTextField();
        pnSumme = new javax.swing.JPanel();
        lbBrutto = new javax.swing.JLabel();
        lbNetto = new javax.swing.JLabel();
        tfBrutto = new javax.swing.JTextField();
        tfNetto = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        cbCategories = new javax.swing.JComboBox();
        dpDate = new org.jdesktop.swingx.JXDatePicker();
        jButton4 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        btOk = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Neue Rechnungen");
        setResizable(false);
        getContentPane().setLayout(new java.awt.BorderLayout(5, 5));

        rbEarning.setSelected(true);
        rbEarning.setText("Einnahmen");
        rbEarning.setActionCommand("e");
        rbEarning.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                on(evt);
            }
        });

        rbOutgoing.setText("Ausgaben");
        rbOutgoing.setActionCommand("a");
        rbOutgoing.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                off(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(rbEarning, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                    .addComponent(rbOutgoing, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(508, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(rbEarning)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbOutgoing)
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

        pnMain.setBorder(javax.swing.BorderFactory.createTitledBorder("Einnahmen"));

        tbAmounts.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbAmounts);

        btNewAmount.setText("Neuer Betrag");
        btNewAmount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onNewValue(evt);
            }
        });

        lbFirma.setText(" Firma:");

        lbDatum.setText(" Datum:");

        tfCompany.setEditable(false);

        pnSumme.setBorder(javax.swing.BorderFactory.createTitledBorder("Summe"));

        lbBrutto.setText("Brutto:");

        lbNetto.setText("Netto:");

        tfBrutto.setEditable(false);
        tfBrutto.setText("               ");

        tfNetto.setEditable(false);
        tfNetto.setText("               ");

        javax.swing.GroupLayout pnSummeLayout = new javax.swing.GroupLayout(pnSumme);
        pnSumme.setLayout(pnSummeLayout);
        pnSummeLayout.setHorizontalGroup(
            pnSummeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnSummeLayout.createSequentialGroup()
                .addGroup(pnSummeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnSummeLayout.createSequentialGroup()
                        .addComponent(lbBrutto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tfBrutto, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))
                    .addGroup(pnSummeLayout.createSequentialGroup()
                        .addComponent(lbNetto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tfNetto)))
                .addContainerGap())
        );
        pnSummeLayout.setVerticalGroup(
            pnSummeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnSummeLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addGroup(pnSummeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfBrutto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbBrutto))
                .addGap(10, 10, 10)
                .addGroup(pnSummeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfNetto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbNetto)))
        );

        jButton1.setText("Betrag löschen");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onDeleteValue(evt);
            }
        });

        jButton2.setText("Betrag ändern");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onChangeValue(evt);
            }
        });

        jButton3.setText("Rechnungskopie");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onBillcopy(evt);
            }
        });

        jLabel1.setText("Kategorie");

        cbCategories.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton4.setText("Auswählen");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onSelectCompany(evt);
            }
        });

        javax.swing.GroupLayout pnMainLayout = new javax.swing.GroupLayout(pnMain);
        pnMain.setLayout(pnMainLayout);
        pnMainLayout.setHorizontalGroup(
            pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMainLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 437, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pnSumme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btNewAmount, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)))
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbFirma)
                            .addComponent(lbDatum))
                        .addGap(36, 36, 36)
                        .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(dpDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tfCompany))
                        .addGap(7, 7, 7)
                        .addComponent(jButton4)
                        .addGap(35, 35, 35)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbCategories, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnMainLayout.setVerticalGroup(
            pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMainLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbFirma)
                    .addComponent(tfCompany, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(cbCategories, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDatum)
                    .addComponent(dpDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(pnSumme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addComponent(btNewAmount)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton3)))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        getContentPane().add(pnMain, java.awt.BorderLayout.CENTER);

        jPanel6.setLayout(new java.awt.GridBagLayout());

        btOk.setText("OK");
        btOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onOk(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(0, 20, 10, 20);
        jPanel6.add(btOk, gridBagConstraints);

        btCancel.setText("Abbrechen");
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onCancel(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(0, 20, 11, 20);
        jPanel6.add(btCancel, gridBagConstraints);

        getContentPane().add(jPanel6, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void on(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_on
        pnMain.setBorder(BorderFactory.createTitledBorder("Einnahmen"));
    }//GEN-LAST:event_on

    private void off(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_off
        pnMain.setBorder(BorderFactory.createTitledBorder("Ausgaben"));
    }//GEN-LAST:event_off

    private void onOk(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onOk
        String category = (String) cbCategories.getSelectedItem();
        Date d = dpDate.getDate();
        System.out.println(d);
        
        if(amounts.size() > 0)
        {
            if(selectedComp != null)
            {
                if(d != null){
                String str = buttonGroup1.getSelection().getActionCommand();
                int type = 0;
                    System.out.println("str:"+str);
                if(str.equals("e"))
                    type = 1;
                    try {
                        bill = new Bill(d, selectedComp, amounts, billCopy, new Category(db.getCatID(category), category), type);
                    } catch (Exception ex) {
                                   JOptionPane.showMessageDialog(null, ex);

                    }
                    System.out.println("NB: " + bill);
                    
                ok = true;
                    System.out.println(ok);
                this.dispose();
                }
                else
                {
                    JOptionPane.showMessageDialog(this, "Sie müssen ein Datum eingeben!", "Error!", JOptionPane.ERROR_MESSAGE);
                }
            }
            else
                JOptionPane.showMessageDialog(this, "Sie müssen eine Firma auswählen!", "Error!", JOptionPane.ERROR_MESSAGE);
        }else
        {
            JOptionPane.showMessageDialog(this, "Bitte geben Sie Beträge ein!", "Error!", JOptionPane.ERROR_MESSAGE);
        }
        
        
    }//GEN-LAST:event_onOk

    private void onCancel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onCancel
        this.dispose();
        ok = false;
        
    }//GEN-LAST:event_onCancel

    private void onNewValue(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onNewValue
        NewAmountDlg na = new NewAmountDlg(this, true, null);
        na.setVisible(true);
        if (na.isOk() && na.getBillAmount() != null) {
            amounts.add(na.getBillAmount());
            tbAmounts.updateUI();
            this.updateBruttoNetto();
        }
    }//GEN-LAST:event_onNewValue

    private void onDeleteValue(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onDeleteValue
        int index = tbAmounts.getSelectedRow();

        if (amounts.size() > 0) {
            amounts.remove(index);
            tbAmounts.updateUI();
            this.updateBruttoNetto();
        }
    }//GEN-LAST:event_onDeleteValue

    private void onChangeValue(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onChangeValue
        int index = tbAmounts.getSelectedRow();

        if (amounts.size() > 0) {
            BillAmount ba = amounts.get(index);
            NewAmountDlg na = new NewAmountDlg(this, true, ba);
            na.setVisible(true);
            if (na.isOk() && na.getBillAmount() != null) {
                ba = na.getBillAmount();
                amounts.remove(index);
                amounts.add(index, ba);
                tbAmounts.updateUI();
                this.updateBruttoNetto();
            }
        }
    }//GEN-LAST:event_onChangeValue

    private void onBillcopy(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onBillcopy
 
        if (billCopy == null) {
            Object[] options = {"Neue Rechung erstellen", "Vorhanede Rechnung auswählen"};
            String text = "Möchten Sie eine neue Rechnung erstellen oder eine Vorhandene auswählen?";
            String title = "Rechnungskopie";

            int selected = JOptionPane.showOptionDialog(null, text, title, 0, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (selected == 1) {
                JFileChooser jfc = new JFileChooser();
                jfc.setFileFilter(new FileNameExtensionFilter("PDF", "pdf"));
                jfc.showOpenDialog(this);
                File sel = jfc.getSelectedFile();
                if (sel.isFile() && sel.getName().endsWith(".pdf")) {
                    billCopy = sel;
                } else {
                    JOptionPane.showMessageDialog(this, "Sie haben keine gültige Datei ausgewählt!", "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else if (selected == 0) {
                CreateBillDlg cbd = new CreateBillDlg(null, true);
                cbd.setVisible(true);
                if (cbd.isOk() && cbd.getFinishedPDF() != null) {
                    billCopy = cbd.getFinishedPDF();
                }
            }
        } else {
            Object[] options = {"Neue Rechung erstellen", "Ausgewählte Rechnung ansehen"};
            String text = "Für diese Rechnung wurde bereits eine Kopie ausgewählt. \n"
                    + "Möchten Sie eine neue definieren?\n"
                    + "ACHTUNG! Die alte Rechnung geht danach verloren!";
            String title = "Rechnungskopie";

            int selected = JOptionPane.showOptionDialog(null, text, title, 0, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if(selected == 0)
            {
                billCopy = null;
                this.onBillcopy(evt);
            }else if(selected == 1)
            {
                ViewCopyDlg vcd = new ViewCopyDlg(null, true, billCopy);
                vcd.setVisible(true);
            }
        }

       

    }//GEN-LAST:event_onBillcopy

    private void onSelectCompany(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onSelectCompany
        ChooseCompanyDlg ccd = new ChooseCompanyDlg(null, true);
        ccd.setVisible(true);
        if(ccd.isOk()){
            tfCompany.setText(ccd.getSelectedCompany().getName());
            selectedComp = ccd.getSelectedCompany();
        }
    }//GEN-LAST:event_onSelectCompany

    public void updateBruttoNetto() {
        BigDecimal brutto = new BigDecimal(0);
        BigDecimal netto = new BigDecimal(0);

        for (BillAmount ba : amounts) {
            brutto = brutto.add(ba.getBrutto());
            netto = netto.add(ba.getNetto());
        }

        if (brutto.doubleValue() > 0) {
            tfBrutto.setText(NumberFormat.getCurrencyInstance().format(brutto.doubleValue()));
        } else {
            tfBrutto.setText("");
        }

        if (netto.doubleValue() > 0) {
            tfNetto.setText(NumberFormat.getCurrencyInstance().format(netto.doubleValue()));
        } else {
            tfNetto.setText("");
        }
    }



    public boolean isOk() {
        return ok;
    }

    public Bill getBill() {
        return bill;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btNewAmount;
    private javax.swing.JButton btOk;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbCategories;
    private org.jdesktop.swingx.JXDatePicker dpDate;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbBrutto;
    private javax.swing.JLabel lbDatum;
    private javax.swing.JLabel lbFirma;
    private javax.swing.JLabel lbNetto;
    private javax.swing.JPanel pnMain;
    private javax.swing.JPanel pnSumme;
    private javax.swing.JRadioButton rbEarning;
    private javax.swing.JRadioButton rbOutgoing;
    private javax.swing.JTable tbAmounts;
    private javax.swing.JTextField tfBrutto;
    private javax.swing.JTextField tfCompany;
    private javax.swing.JTextField tfNetto;
    // End of variables declaration//GEN-END:variables
}
